package com.im.server.enterprise.manage.controller;

import javax.annotation.Resource;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;

import com.im.base.common.util.KeyUtil;
import com.im.server.enterprise.business.push.DepartmentPush;
import com.im.server.enterprise.common.manager.DepartmentMemberManager;
import com.only.common.result.ResultMessage;
import com.only.general.annotation.action.ActionMapping;
import com.only.general.annotation.action.MethodMapping;
import com.only.general.annotation.parameter.Define;

@Controller
@ActionMapping("department")
public class DepartmentController {
	protected final Logger logger = LogManager.getLogger(this.getClass());
	
	@Resource
	DepartmentMemberManager departmentMemberManager;
	@Resource
	DepartmentPush departmentPush;
	
	@MethodMapping("refreshDepartmentData")
	public Object refreshDepartmentData(@Define("departmentId") String departmentId) {
		ResultMessage message = new ResultMessage();
		String key=KeyUtil.getKey();
		departmentPush.pushDepartmentUpdate(key, departmentId);
		return message;
	}

	@MethodMapping("refreshDepartmentList")
	public Object refreshDepartmentList() {
		departmentMemberManager.loadDepartmentMemberList();
		String key=KeyUtil.getKey();
		departmentPush.pushDepartmentListUpdate(key);
		ResultMessage message = new ResultMessage();
		return message;
	}
	
	@MethodMapping("refreshDepartmentMemberList")
	public Object refreshDepartmentMemberList() {
		departmentMemberManager.loadDepartmentMemberList();
		String key=KeyUtil.getKey();
		departmentPush.pushDepartmentMemberListUpdate(key);
		ResultMessage message = new ResultMessage();
		return message;
	}
}
